<script type="text/javascript">
function validate_form() {
    <?php
        if(count($this->language) > 0) :
            foreach($this->language as $value) :
    ?>
    if($('#tabs-<?php echo $value['locale'] ?>').hasClass('ui-tabs-hide') == false) {
        var image = $('#image').val();
        var name_<?php echo $value['locale'] ?> = $('#name-<?php echo $value['locale'] ?>').val();
        var address_<?php echo $value['locale'] ?> = tinyMCE.get('address-<?php echo $value['locale'] ?>').getContent();
        var description_<?php echo $value['locale'] ?> = tinyMCE.get('description-<?php echo $value['locale'] ?>').getContent();
        var policy_<?php echo $value['locale'] ?> = tinyMCE.get('policy-<?php echo $value['locale'] ?>').getContent();
        var cozy_<?php echo $value['locale'] ?> = tinyMCE.get('cozy-<?php echo $value['locale'] ?>').getContent();
        var condition_<?php echo $value['locale'] ?> = tinyMCE.get('condition-<?php echo $value['locale'] ?>').getContent();
        var countError = 0;
        if((name_<?php echo $value['locale'] ?>.length < 1) || (name_<?php echo $value['locale'] ?>.length > 100)) {
            $('#errorName-<?php echo $value['locale'] ?>').html('Tên du thuyền từ 1-100 kí tự');
            countError++;
        }
        else {
            $('#errorName-<?php echo $value['locale'] ?>').html('');
        }
        if((address_<?php echo $value['locale'] ?>.length < 1) || (address_<?php echo $value['locale'] ?>.length > 300)) {
            $('#errorAddress-<?php echo $value['locale'] ?>').html('Địa chỉ từ 1-300 kí tự');
            countError++;
        }
        else {
            $('#errorAddress-<?php echo $value['locale'] ?>').html('');
        }
        if(description_<?php echo $value['locale'] ?> == '') {
            $('#errorDescription-<?php echo $value['locale'] ?>').html('Giới thiệu về du thuyền không được để trống');
            countError++;
        }
        else {
            $('#errorDescription-<?php echo $value['locale'] ?>').html('');
        }
        if(policy_<?php echo $value['locale'] ?> == '') {
            $('#errorPolicy-<?php echo $value['locale'] ?>').html('Chính sách du thuyền không được để trống');
            countError++;
        }
        else {
            $('#errorPolicy-<?php echo $value['locale'] ?>').html('');
        }
        if(cozy_<?php echo $value['locale'] ?> == '') {
            $('#errorCozy-<?php echo $value['locale'] ?>').html('Tiện nghi không được để trống');
            countError++;
        }
        else {
            $('#errorCozy-<?php echo $value['locale'] ?>').html('');
        }
        if(condition_<?php echo $value['locale'] ?> == '') {
            $('#errorCondition-<?php echo $value['locale'] ?>').html('Điều kiện hủy phòng không được để trống');
            countError++;
        }
        else {
            $('#errorCondition-<?php echo $value['locale'] ?>').html('');
        }
        if(!/(\.png|\.gif|\.jpg|\.jpeg\.PNG|\.GIF|\.JPG|\.JPEG)$/i.test(image)) {
            $('#errorImage').html('Ảnh phải đúng định dạng jpg, jpeg, png, gif');
            countError++; 
        }
        else {
            $('#errorImage').html('');
        }
        if(countError > 0) {
            return false;
        }
        else {
            return true;
        }
    }
    <?php
            endforeach;
        endif;
    ?>
};
</script>
<div class="list_category">
        <ul>
            <li><a href="<?php echo $this->baseUrl('admincp/boating'); ?>">Quản lý du thuyền</a></li>
        </ul>
    </div>
</div>

<!-- Begin Content -->
<div class="section">
    <div class="heading_section">
        <span>Tạo du thuyền mới</span>
    </div>
    
    <div class="content">
    <form action="" method="post" onsubmit="return validate_form()" enctype="multipart/form-data">
        <div id="tabs">
            <ul>
                <?php
                    if(count($this->language) > 0) :
                        foreach($this->language as $value) :
                ?>
                    <li><a href="#tabs-<?php echo $value['locale']; ?>"><?php echo $value['name']; ?></a></li>
                <?php
                        endforeach;
                    endif;
                ?>
            </ul>
            
            <?php
                if(count($this->language) > 0) :
                    foreach($this->language as $value) :
            ?>
            <div id="tabs-<?php echo $value['locale']; ?>">
                <table class="table">
                    <tr>
                        <td class="td1"><?php echo $this->formLabel('name-'.$value['locale'],'Tên du thuyền'); ?>&nbsp;<span class="error-msg">*</span></td>
                        <td class="td2"><?php echo $this->formText('name-'.$value['locale'],null,array('class'=>'input','style'=>'width:295px')); ?></td>
                        <td class="td3" id="errorName-<?php echo $value['locale']; ?>"></td>
                    </tr>
                    <tr>
                        <td class="td1"><?php echo $this->formLabel('address-'.$value['locale'],'Địa chỉ'); ?>&nbsp;<span class="error-msg">*</span></td>
                        <td class="td2"><?php echo $this->formTextarea('address-'.$value['locale'],null,array('cols'=>40,'rows'=>3,'style'=>'resize:none;')); ?></td>
                        <td class="td3" id="errorAddress-<?php echo $value['locale']; ?>"></td>
                    </tr>
                    <tr>
                        <td class="td1"><?php echo $this->formLabel('description-'.$value['locale'],'Giới thiệu về du thuyền'); ?>&nbsp;<span class="error-msg">*</span></td>
                        <td class="td2"><?php echo $this->formTextarea('description-'.$value['locale'],null,array('class'=>'ckeditor','style'=>'height: 100px;')); ?></td>
                        <td class="td3" id="errorDescription-<?php echo $value['locale']; ?>"></td>
                    </tr>
                    <tr>
                        <td class="td1"><?php echo $this->formLabel('policy-'.$value['locale'],'Chính sách du thuyền'); ?>&nbsp;<span class="error-msg">*</span></td>
                        <td class="td2"><?php echo $this->formTextarea('policy-'.$value['locale'],null,array('class'=>'ckeditor','style'=>'height: 100px;')); ?></td>
                        <td class="td3" id="errorPolicy-<?php echo $value['locale']; ?>"></td>
                    </tr>
                    <tr>
                        <td class="td1"><?php echo $this->formLabel('cozy-'.$value['locale'],'Tiện nghi'); ?>&nbsp;<span class="error-msg">*</span></td>
                        <td class="td2"><?php echo $this->formTextarea('cozy-'.$value['locale'],null,array('class'=>'ckeditor')); ?></td>
                        <td class="td3" id="errorCozy-<?php echo $value['locale']; ?>"></td>
                    </tr>
                    <tr>
                        <td class="td1"><?php echo $this->formLabel('condition-'.$value['locale'],'Điều kiện hủy phòng'); ?>&nbsp;<span class="error-msg">*</span></td>
                        <td class="td2"><?php echo $this->formTextarea('condition-'.$value['locale'],null,array('class'=>'ckeditor')); ?></td>
                        <td class="td3" id="errorCondition-<?php echo $value['locale']; ?>"></td>
                    </tr>
                </table>
            </div>
            <?php
                    endforeach;
                endif;
            ?>
            
            <table class="table">
                <tr>
                    <td class="td1"><?php echo $this->formLabel('star', 'Cấp độ'); ?></td>
                    <td class="td2">
                        <select name="star" id="star" class="selectbox">
                        <?php echo $this->star; ?>
                        </select>
                    </td>
                    <td class="td3"></td>
                </tr>
                <tr>
                    <td class="td1"><?php echo $this->formLabel('image', 'Ảnh du thuyền'); ?></td>
                    <td class="td2"><input type="file" name="image" id="image" /></td>
                    <td class="td3" id="errorImage"></td>
                </tr>
                <tr>
                    <td class="td1">&nbsp;</td>
                    <td class="td2">
                        <?php echo $this->formSubmit('submit','Chấp nhận',array('class'=>'button')); ?>
                        <?php echo $this->formReset('reset','Nhập lại',array('class'=>'button')); ?>
                    </td>
                    <td class="td3"></td>
                </tr>
            </table>
        </div>
    </form>
    </div>
</div>
<!-- End Content -->